package com.google.gwt.vector.client.ui;

/**
 */
public class Color {
  public static final Color AQUA = new Color(0, 255, 255);
  public static final Color BLACK = new Color(0, 0, 0);
  public static final Color BLUE = new Color(0, 0, 255);
  public static final Color FUCHSIA = new Color(255, 0, 255);
  public static final Color GREY = new Color(128, 128, 128);
  public static final Color GREEN = new Color(0, 128, 0);
  public static final Color LIME = new Color(0, 255, 0);
  public static final Color MAROON = new Color(128, 0, 0);
  public static final Color NAVY = new Color(0, 0, 128);
  public static final Color NONE = new Color("");
  public static final Color OLIVE = new Color(128, 128, 0);
  public static final Color PURPLE = new Color(128, 0, 128);
  public static final Color RED = new Color(255, 0, 0);
  public static final Color SILVER = new Color(192, 192, 192);
  public static final Color TEAL = new Color(0, 128, 128);
  public static final Color WHITE = new Color(255, 255, 255);
  public static final Color YELLOW = new Color(255, 255, 0);

  private String r, g, b;

  private String colorText = null;

  private Color(String colorText) {
    this.colorText = colorText;
  }

  public Color(int r, int g, int b) {
    this.r = pad(Integer.toHexString(r));
    this.g = pad(Integer.toHexString(g));
    this.b = pad(Integer.toHexString(b));
  }

  public String getHexValue() {
    if (colorText != null) {
      return colorText;
    }

    return "#" + r + g + b;
  }

  private String pad(String in) {
    if (in.length() == 0) {
      return "00";
    }
    if (in.length() == 1) {
      return "0" + in;
    }
    return in;
  }

}
